package asr_server

import (
	"fmt"
	"sync"
	"xiaozhi/config"
)

type AsrServer interface {
	Init()
	Start()
	Stop()
	OnMessage(data []byte)
	OnClose()
	OnError(err error)
	OnOpen()
	OnConnect()
	OnDisconnect()
}

var (
	lk     sync.Mutex
	reqNum int64
	fail   int64
)

type Asr struct {
	/*Type
	 * stt
	 */
	Type string `json:"type"`
	/*Text
	 * 识别结果
	 */
	Text   string `json:"text"`
	State  string `json:"state"`
	Result chan string
}

func (asr *Asr) OnMessage(data []byte) {
	fmt.Println("asr start")
	switch config.NewSysConfig().AsrType {
	case config.NewSysServerType().AliYun:
		//buff := make([]byte, 0)
		//for buffer := range data {
		//	asr.OnALYAsr(buffer)
		//	fmt.Println(buffer)
		//	//buff = append(buff, buffer...)
		//}
		asr.OnALYAsr(data)
	}
	fmt.Println("asr end")
}
